//
//  PreferencesRangeSliderCell.m
//  League
//
//  Created by JackChen on 2018/2/20.
//  Copyright © 2018年 ciyuanjuzhen. All rights reserved.
//

#import "PreferencesRangeSliderCell.h"
#import "TTRangeSlider.h"

@interface PreferencesRangeSliderCell ()<TTRangeSliderDelegate>

@end

@implementation PreferencesRangeSliderCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelectNum {
    for(UIView *view in [self.sliderContentView subviews]) {
        //先移除
        [view removeFromSuperview];
    }
    self.rangeSlider = [[TTRangeSlider alloc] initWithFrame: CGRectMake(0, 0, kScreenWidth - 100, 60) :self.min andselectedMini:self.selectmin andmaxV:self.max andselectedMaxi:self.selectmax];
    self.rangeSlider.delegate = self;
    self.rangeSlider.tag = 201;
    [self.sliderContentView addSubview:self.rangeSlider];
}

#pragma mark -- TTRangeSliderDelegate
- (void)rangeSlider:(TTRangeSlider *)sender didChangeSelectedMinimumValue:(float)selectedMinimum andMaximumValue:(float)selectedMaximum{
    ProfileManager *manager = [ProfileManager shareManager];
    if (self.max == 220) {
        //代表身高
        if (self.isProfile == YES) {
            manager.height = (NSInteger)selectedMaximum;
        } else {
            manager.heightmin = (NSInteger)selectedMinimum;
            manager.heightmax = (NSInteger)selectedMaximum;
        }
    }
    if (self.max == 100) {
        //代表年龄
        if (self.isProfile == YES) {
            manager.age = (NSInteger)selectedMaximum;
        } else {
            manager.agemin = (NSInteger)selectedMinimum;
            manager.agemax = (NSInteger)selectedMaximum;
        }
    }
}

@end
